From 589aaab18f40f788fd901fdafc221f2b3d144457 Mon Sep 17 00:00:00 2001 From: "tw275@labyrinth.cl.cam.ac.uk" Date: Mon, 26 Jul 2004 16:18:02 +0000 Subject: [PATCH] bitkeeper revision 1.1108.19.1 (41052eba3ZVcoufgBgwBIOi8WV_BbQ) Started to implement the Create Domain Wizzard. Doesn't work yet (along way off). Slight refactoring of other code to make it more extensible --- .rootkeys | 4 ++ tools/python/xen/sv/CreateDomain.py | 43 ++++++++++++++++++ tools/python/xen/sv/DomInfo.py | 18 +++----- tools/python/xen/sv/DomList.py | 2 +- tools/python/xen/sv/GenTabbed.py | 23 +++------- tools/python/xen/sv/Main.py | 42 ++++++++++-------- tools/python/xen/sv/NodeInfo.py | 5 +-- tools/python/xen/sv/Wizzard.py | 66 ++++++++++++++++++++++++++++ tools/python/xen/sv/util.py | 12 ++--- tools/sv/Makefile | 3 ++ tools/sv/images/next.png | Bin 0 -> 1270 bytes tools/sv/images/previous.png | Bin 0 -> 1285 bytes 12 files changed, 161 insertions(+), 57 deletions(-) create mode 100644 tools/python/xen/sv/CreateDomain.py create mode 100755 tools/python/xen/sv/Wizzard.py create mode 100644 tools/sv/images/next.png create mode 100644 tools/sv/images/previous.png diff --git a/.rootkeys b/.rootkeys index b888478532..f4c179832c 100644 --- a/.rootkeys +++ b/.rootkeys @@ -369,6 +369,7 @@ 40dc4076St6AmPTmQPrtQ6LGHPxGmw tools/python/xen/lowlevel/xu/__init__.py 40dc4076pVeE1kEEWzcUaNZin65kCA tools/python/xen/lowlevel/xu/domain_controller.h 40dc4076CwBYRTUQDdbdU1L6KcLgSw tools/python/xen/lowlevel/xu/xu.c +41052eb84_irpx0E9N_kqBp9eoin5g tools/python/xen/sv/CreateDomain.py 40fcefb2qm13BbRZBydAatOavaS0fQ tools/python/xen/sv/DomInfo.py 40fcefb2-RIU8GB67mJMRzybME9bxw tools/python/xen/sv/DomList.py 40fcefb23FfQn-ZBCbcHqA0cPGqQxw tools/python/xen/sv/GenTabbed.py @@ -376,6 +377,7 @@ 40fcefb2vnfDbl4w_yCTedROPuqs0g tools/python/xen/sv/Main.py 40fcefb24h-04WaHag-Tg4nxWPhTig tools/python/xen/sv/NodeInfo.py 40fcefb2Sif__6AqrANeBQZZfvP-6w tools/python/xen/sv/TabView.py +41052eb8UrgtUkuJPg7oY1tutVQHsg tools/python/xen/sv/Wizzard.py 40fcefb2DqteqCCZYDCvvh4Q5jBd0w tools/python/xen/sv/__init__.py 40fcefb4rnaZNjqsBu7A5V2rlLyqRw tools/python/xen/sv/util.py 40d8915cyoVA0hJxiBFNymL7YvDaRg tools/python/xen/util/Brctl.py @@ -440,9 +442,11 @@ 40fcefb3K6ESt5sQhD9aCQRscQIlXQ tools/sv/images/left-end-no-highlight.jpg 40fcefb3BUT98zPzW8kAFKuxGdh4XA tools/sv/images/middle-highlight.jpg 40fcefb38OTgsUKHBpwshLLIsiIaCA tools/sv/images/middle-no-highlight.jpg +41052eb9SDUqSLGtG6rxk6Ep5fOhFA tools/sv/images/next.png 40fcefb32SPtrw36c4S6YGFlLvkKuw tools/sv/images/orb_01.jpg 40fcefb3Ok5qkX3iM7ZEPVkRInrUpg tools/sv/images/orb_02.jpg 4104ffca9_GhWOxRE-83uZIad2Z1gg tools/sv/images/pause.png +41052eb9NQqHe_f9-ev1CaA3y5YYZg tools/sv/images/previous.png 41013a82ILk71xLqWFH5ZO5VmOIvBw tools/sv/images/reboot.png 40fcefb3JnT5XeKTuVF4yUMGOtuNZg tools/sv/images/right-end-highlight.jpg 40fcefb3-DuYOS7noo2W7b_0p7TOUg tools/sv/images/right-end-no-highlight.jpg diff --git a/tools/python/xen/sv/CreateDomain.py b/tools/python/xen/sv/CreateDomain.py new file mode 100644 index 0000000000..13c45d8622 --- /dev/null +++ b/tools/python/xen/sv/CreateDomain.py @@ -0,0 +1,43 @@ +from xen.sv.Wizzard import Wizzard, Sheet + +class CreateDomain( Wizzard ): + def __init__( self, urlWriter ): + + sheets = { 0: CreatePage0, + 1: CreatePage1, + 2: CreatePage2, + 3: CreatePage3 } + + Wizzard.__init__( self, urlWriter, "Create Domain Wizzard", sheets ) + +class CreatePage0( Sheet ): + + def __init__( self, urlWriter ): + + feilds = [( 'name', 'Name')] + + Sheet.__init__( self, urlWriter, feilds, "Create New Domain - 1" ) + +class CreatePage1( Sheet ): + + def __init__( self, urlWriter ): + + feilds = [( 'name', 'Name')] + + Sheet.__init__( self, urlWriter, feilds, "Create New Domain - 2" ) + +class CreatePage2( Sheet ): + + def __init__( self, urlWriter ): + + feilds = [( 'name', 'Name')] + + Sheet.__init__( self, urlWriter, feilds, "Create New Domain - 3" ) + +class CreatePage3( Sheet ): + + def __init__( self, urlWriter ): + + feilds = [( 'name', 'Name')] + + Sheet.__init__( self, urlWriter, feilds, "Create New Domain - 4" ) \ No newline at end of file diff --git a/tools/python/xen/sv/DomInfo.py b/tools/python/xen/sv/DomInfo.py index 7e23ab792d..6f8ac1ab5b 100755 --- a/tools/python/xen/sv/DomInfo.py +++ b/tools/python/xen/sv/DomInfo.py @@ -12,7 +12,7 @@ class DomInfo( GenTabbed ): self.dom = 0; def tabUrlWriter( tab ): - return urlWriter( "mod=info&dom=%s%s" % ( self.dom, tab ) ) + return urlWriter( "&dom=%s%s" % ( self.dom, tab ) ) GenTabbed.__init__( self, "Domain Info", tabUrlWriter, [ 'General', 'SXP', 'Devices' ], [ DomGeneralTab, DomSXPTab, NullTab ] ) @@ -52,13 +52,11 @@ class DomGenTab( GeneralTab ): def write_BODY( self, request ): - dom = request.args.get('dom') + self.dom = getVar('dom', request) - if dom is None or len(dom) != 1: + if self.dom is None: request.write( "

Please Select a Domain

" ) return None - else: - self.dom = dom[0] self.dict = getDomInfoHash( self.dom ) @@ -72,17 +70,15 @@ class DomSXPTab( PreTab ): def write_BODY( self, request ): - dom = request.args.get('dom') + self.dom = getVar('dom', request) - if dom is None or len(dom) != 1: + if self.dom is None: request.write( "

Please Select a Domain

" ) return None - else: - self.dom = dom[0] - + domInfo = server.xend_domain( self.dom ) - self.source = sxp2string( domInfo ) + self.source = sxp2prettystring( domInfo ) PreTab.write_BODY( self, request ) diff --git a/tools/python/xen/sv/DomList.py b/tools/python/xen/sv/DomList.py index 82f7cc424b..145016cded 100755 --- a/tools/python/xen/sv/DomList.py +++ b/tools/python/xen/sv/DomList.py @@ -43,7 +43,7 @@ class DomList( HTMLBase ): def write_DOMAIN( self, request, domInfoHash, long=True ): request.write( "%(dom)-4d\n" % domInfoHash ) - url = self.urlWriter( "mod=info&dom=%(dom)-4d" % domInfoHash ) + url = self.urlWriter( "&mod=info&dom=%(dom)-4d" % domInfoHash ) request.write( "%s\n" % ( url, domInfoHash['name'] ) ) if long: diff --git a/tools/python/xen/sv/GenTabbed.py b/tools/python/xen/sv/GenTabbed.py index 1d5bd2d22a..aef1848e7a 100755 --- a/tools/python/xen/sv/GenTabbed.py +++ b/tools/python/xen/sv/GenTabbed.py @@ -2,35 +2,31 @@ import types from xen.sv.HTMLBase import HTMLBase from xen.sv.TabView import TabView +from xen.sv.util import getVar class GenTabbed( HTMLBase ): def __init__( self, title, urlWriter, tabStrings, tabObjects ): HTMLBase.__init__(self) - self.tab = 0; self.tabStrings = tabStrings self.tabObjects = tabObjects self.urlWriter = urlWriter self.title = title def write_BODY( self, request, urlWriter = None ): - tab = request.args.get('tab') - - if tab is None or len( tab) != 1: - self.tab = 0 - else: - self.tab = int( tab[0] ) + + tab = int( getVar( 'tab', request, 0 ) ) request.write( "" ) request.write( "
" ) request.write( "

%s

" % self.title ) - TabView( self.tab, self.tabStrings, self.urlWriter ).write_BODY( request ) + TabView( tab, self.tabStrings, self.urlWriter ).write_BODY( request ) request.write( "
" ) - render_tab = self.tabObjects[ self.tab ] + render_tab = self.tabObjects[ tab ] if render_tab is None: request.write( "

Bad Tab

" ) @@ -41,14 +37,9 @@ class GenTabbed( HTMLBase ): request.write( "
" ) def perform( self, request ): - tab = request.args.get('tab') - - if tab is None or len( tab) != 1: - self.tab = 0 - else: - self.tab = int( tab[0] ) + tab = int( getVar( 'tab', request, 0 ) ) - op_tab = self.tabObjects[ self.tab ] + op_tab = self.tabObjects[ tab ] if op_tab: op_tab().perform( request ) diff --git a/tools/python/xen/sv/Main.py b/tools/python/xen/sv/Main.py index 9de097a1d4..bf6119c600 100755 --- a/tools/python/xen/sv/Main.py +++ b/tools/python/xen/sv/Main.py @@ -2,35 +2,40 @@ from xen.sv.HTMLBase import HTMLBase from xen.sv.DomList import DomList from xen.sv.NodeInfo import NodeInfo from xen.sv.DomInfo import DomInfo +from xen.sv.CreateDomain import CreateDomain + +from xen.sv.util import getVar class Main( HTMLBase ): isLeaf = True def __init__( self, urlWriter = None ): - self.modules = { "node": ( "Node details", NodeInfo ), - "list": ( "Domain summary", DomList ), - "info": ( "Domain info", DomInfo ) } + self.modules = { "node": NodeInfo, + "list": DomList, + "info": DomInfo, + "create": CreateDomain } HTMLBase.__init__(self) def render_POST( self, request ): #decide what module post'd the action - mod = request.args.get('mod') + mod = getVar( 'mod', request ) - if not mod is None and len(mod) == 1: - modTup = self.modules[ mod[0] ] + if not mod is None: + module = self.modules[ mod ] #check module exists - if modTup: - (modName, module) = modTup + if module: module( self.mainUrlWriter ).perform( request ) return self.render_GET( request ) - def mainUrlWriter( self, s ): - return "Main.rpy?%s" % s - + def mainUrlWriter( self, module ): + def fun( f ): + return "Main.rpy?mod=%s%s" % ( module, f ) + return fun + def write_BODY( self, request ): request.write( "\n\n" ) @@ -43,8 +48,8 @@ class Main( HTMLBase ): request.write( " ") request.write( " " ) request.write( "

SV Web Interface
(C) Tom Wilkie 2004

" ) - for (modName, (modTitle, module)) in self.modules.items(): - module( self.mainUrlWriter ).write_MENU( request ) + for (modName, module) in self.modules.items(): + module( self.mainUrlWriter( modName ) ).write_MENU( request ) request.write( "
" ) @@ -56,15 +61,14 @@ class Main( HTMLBase ): request.write( " " ) request.write( " " ) - mod = request.args.get('mod') + modName = getVar('mod', request) - if mod is None or len(mod) != 1: + if modName is None: request.write( '

Please select a module

' ) else: - modTup = self.modules[ mod[0] ] - if modTup: - (modName, module) = modTup - module( self.mainUrlWriter ).write_BODY( request ) + module = self.modules[ modName ] + if module: + module( self.mainUrlWriter( modName ) ).write_BODY( request ) else: request.write( '

Invalid module. Please select another

' ) diff --git a/tools/python/xen/sv/NodeInfo.py b/tools/python/xen/sv/NodeInfo.py index a3aac1d34c..948acef4b6 100755 --- a/tools/python/xen/sv/NodeInfo.py +++ b/tools/python/xen/sv/NodeInfo.py @@ -7,10 +7,7 @@ class NodeInfo( GenTabbed ): def __init__( self, urlWriter ): - def newUrlWriter( url ): - return urlWriter( "mod=node%s" % url ) - - GenTabbed.__init__( self, "Node Details", newUrlWriter, [ 'General', 'Dmesg', ], [ NodeGeneralTab, NodeDmesgTab ] ) + GenTabbed.__init__( self, "Node Details", urlWriter, [ 'General', 'Dmesg', ], [ NodeGeneralTab, NodeDmesgTab ] ) def write_MENU( self, request ): request.write( "

Node details

" % self.urlWriter( '' ) ) diff --git a/tools/python/xen/sv/Wizzard.py b/tools/python/xen/sv/Wizzard.py new file mode 100755 index 0000000000..0f506d03b8 --- /dev/null +++ b/tools/python/xen/sv/Wizzard.py @@ -0,0 +1,66 @@ +from xen.sv.util import * +from xen.sv.HTMLBase import HTMLBase +from xen.xend import sxp + +class Wizzard( HTMLBase ): + + def __init__( self, urlWriter, title, sheets ): + HTMLBase.__init__( self ) + self.title = title + self.sheets = sheets + self.currSheet = 0 + self.urlWriter = urlWriter + + def write_MENU( self, request ): + request.write( "

%s

" % (self.urlWriter( '' ), self.title) ) + + def write_BODY( self, request ): + + request.write( "
" ) + request.write( "

%s

" % self.title ) + + currSheet = getVar( 'sheet', request ) + + if not currSheet is None: + + self.currSheet = int( currSheet ) + + self.sheets[ self.currSheet ]( self.urlWriter ).write_BODY( request ) + + request.write( "
" ) + request.write( "
" ) + request.write( "

 " ) + request.write( "

" ) + request.write( "

" ) + request.write( "
" ) + +class Sheet( HTMLBase ): + + def __init__( self, urlWriter, feilds, title ): + HTMLBase.__init__( self ) + self.urlWriter = urlWriter + self.feilds = feilds + self.title = title + + def parseForm( self, request ): + return sxp.toString( request.args ) + + def write_BODY( self, request ): + request.write( "

%s

" % self.title ) + + previous_values = request.args + + for (feild, name) in self.feilds: + value = sxp.child_value( previous_values, feild ) + if value is None: + value = '' + request.write( "

%s

" % (name, feild, value) ) + + def op_next( self, request ): + pass + + def op_prev( self, request ): + pass + + + diff --git a/tools/python/xen/sv/util.py b/tools/python/xen/sv/util.py index 57940d9287..adf75b073c 100755 --- a/tools/python/xen/sv/util.py +++ b/tools/python/xen/sv/util.py @@ -18,9 +18,9 @@ def sxp2hash( s ): else: sxphash[ child[0] ] = child[1] - return sxphash + return sxphash -def sxp2string( sxp ): +def sxp2prettystring( sxp ): class tmp: def __init__( self ): self.str = "" @@ -30,14 +30,14 @@ def sxp2string( sxp ): PrettyPrint.prettyprint( sxp, out=temp ) return temp.str -def getVar( var, request ): +def getVar( var, request, default=None ): arg = request.args.get( var ) - if arg is None or len(arg) != 1: - return None + if arg is None: + return default else: - return arg[0] + return arg[ len( arg )-1 ] def bigTimeFormatter( time ): time = float( time ) diff --git a/tools/sv/Makefile b/tools/sv/Makefile index 8a63d4ac1b..b8f2a7a116 100755 --- a/tools/sv/Makefile +++ b/tools/sv/Makefile @@ -33,6 +33,9 @@ install: install -m0644 images/reboot.png $(sv_insdir)/images install -m0644 images/pause.png $(sv_insdir)/images install -m0644 images/unpause.png $(sv_insdir)/images + + install -m0644 images/next.png $(sv_insdir)/images + install -m0644 images/previous.png $(sv_insdir)/images # make include folder mkdir -p $(sv_insdir)/inc diff --git a/tools/sv/images/next.png b/tools/sv/images/next.png new file mode 100644 index 0000000000000000000000000000000000000000..da10bbfb9b48eeebdfdebea4c05bd29648fed054 GIT binary patch literal 1270 zcmV?bz6rVnQ>h|v4JG-}U-)epM@Im_j|Nm@2<-fSN zxL%5ji(h7CWj&^(q_iEV{_fwue;Gc1{>mdTuC87O^zkGhX88U4H(U)s z0HIh03=SrsZ#s@0J5~yFG0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